package demo05;

public class CarInsurance implements Insurance {
    private  double carValue;
    private  int accidentCount;
    public  CarInsurance(double CarValue,int accidentCount){
        this.carValue=carValue;
        this.accidentCount=accidentCount;
    }
    @Override
    public double a() {
        double basePremium=carValue*0.02;
        if(accidentCount==0){
            return  basePremium;
        }
        else if(accidentCount==1){
            return  basePremium+basePremium*0.1;
        }
        else {
            return basePremium+basePremium*0.2;
        }
    }

}
